package com.lego.bean;

import java.util.List;

public class PersonalReviewVO<T>{
	private List<T> ordersAndGoodsImgVO;
	private int pageNum;
	private int pageSize;
	private boolean hasPrev;
	private boolean hasNext;
	private int[] navigatorNums;
	private int totalPages;
	private int totalRows;
	
	public List<T> getOrdersAndGoodsImgVO() {
		return ordersAndGoodsImgVO;
	}
	public void setOrdersAndGoodsImgVO(List<T> ordersAndGoodsImgVO) {
		this.ordersAndGoodsImgVO = ordersAndGoodsImgVO;
	}
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public boolean isHasPrev() {
		return hasPrev;
	}
	public void setHasPrev(boolean hasPrev) {
		this.hasPrev = hasPrev;
	}
	public boolean isHasNext() {
		return hasNext;
	}
	public void setHasNext(boolean hasNext) {
		this.hasNext = hasNext;
	}
	public int[] getNavigatorNums() {
		return navigatorNums;
	}
	public void setNavigatorNums(int[] navigatorNums) {
		this.navigatorNums = navigatorNums;
	}
	public int getTotalPages() {
		return totalPages;
	}
	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}
	public int getTotalRows() {
		return totalRows;
	}
	public void setTotalRows(int totalRows) {
		this.totalRows = totalRows;
	}
	public PersonalReviewVO(List<T> ordersAndGoodsImgVO, int pageNum, int pageSize, int totalRows) {
		super();
		this.ordersAndGoodsImgVO = ordersAndGoodsImgVO;
		this.pageNum = pageNum;
		this.pageSize = pageSize;
		this.totalRows = totalRows;
		
		if((totalRows%pageSize)!=0) {
			this.totalPages = (totalRows/pageSize)+1;
		}else {
			this.totalPages = totalRows/pageSize;
		}
		
		if(pageNum<=1) {
			this.hasPrev = false;
		}else {
			this.hasPrev = true;
		}
		
		if(pageNum>=totalPages) {
			this.hasNext = false;
		}else {
			this.hasNext = true;
		}
		
		if(totalPages<10) {
			this.navigatorNums = new int[totalPages];
		}else {
			this.navigatorNums = new int[10];
		}
		
		if(pageNum<=5) {
			for (int i = 0; i < navigatorNums.length; i++) {
				navigatorNums[i] = i+1;
			}
		}else if(pageNum>5&&pageNum+5<=totalPages) {
			for (int i = pageNum-4,k = 0; i <= pageNum+5; i++,k++) {
				navigatorNums[k] = i;
			}
		}else {
			for (int i = totalPages-navigatorNums.length+1,k = 0; i <= totalPages; i++,k++) {
				navigatorNums[k] = i;
			}
		}
	}
	public PersonalReviewVO() {
	}
	
}
